package com.huluobo.a2208kotlindouyindemo.shop

import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.huluobo.a2208kotlindouyindemo.R
import com.huluobo.a2208kotlindouyindemo.adapter.CommentAdapter
import com.huluobo.a2208kotlindouyindemo.databinding.FragmentCommentBinding
import com.huluobo.base.mvvm.BaseFragment
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class CommentFragment : BaseFragment<FragmentCommentBinding, ShopViewModel>() {
    private lateinit var commentAdapter: CommentAdapter
    override fun initData() {
        vm.getComment(166)
        vm.getCommentSuccess.observe(this) {
            commentAdapter.data.clear()
            commentAdapter.data.addAll(it)
            commentAdapter.notifyDataSetChanged()
        }
    }

    override fun initView() {
        binding.commentRv.layoutManager = LinearLayoutManager(requireContext())
        commentAdapter = CommentAdapter()
        binding.commentRv.adapter = commentAdapter
    }
}